/**
 * Created by Ysssssss on 21/1/14.
 */

import React from 'react';
import ReactDOM from 'react-dom';

import { Provider } from "react-redux";
import {ConfigProvider} from 'antd';
import zhCN from 'antd/es/locale/zh_CN';
import AppRouter from "@routes/AppRouter";

import createSagaMiddleware from 'redux-saga';
import { createLogger } from 'redux-logger'
import { applyMiddleware, createStore, combineReducers } from 'redux'
import reducers from '@reducers/index'
import rootSaga from '@sagas/index'
import LoadingPage from "@common/LoadingPage";
import moment from 'moment';
import 'moment/locale/zh-cn';
moment.locale('zh-cn');

const sagaMiddleware = createSagaMiddleware();

const rootReducer = combineReducers(reducers)

const isDev = (process.env.NODE_ENV !== 'production')

const store = createStore(
    rootReducer,
    {},
    isDev ? applyMiddleware(sagaMiddleware, createLogger()) : applyMiddleware(sagaMiddleware)
)

sagaMiddleware.run(rootSaga);


const App = () => (
    <ConfigProvider locale={zhCN}>
        <Provider store={store} >
            <AppRouter/>
            <LoadingPage />
        </Provider>
    </ConfigProvider>
);


ReactDOM.render(<App/>, document.getElementById('app'));
